<HTML> 
<HEAD> 
	<TITLE>3rd Party ROBOTC Drivers</TITLE> 
<link href="tabs.css" rel="stylesheet" type="text/css"/> 
<link href="doxygen.css" rel="stylesheet" type="text/css"/> 
</HEAD> 
 
<BODY bgcolor="#ffffff" link="#000000" vlink="#000000"> 
<table width="100%" bgcolor="navy" cellspacing=0 cellpadding=1 border=0> 
<tr><td><table width="100%" bgcolor="#EEEEDD" cellspacing=0 cellpadding=3 border=0> 
<tr> 
    <td width="33%" align="left"> <img src="images/LOGO_NXT.gif" width=266 height=44 border="0" alt="Mindstorms"></td> 
    <td><b><font size="+3" color="navy">3rd Party ROBOTC Drivers</font></b></td> 
    <td align="right"> <img src="images/logo.png" width=44 height=44 border="0" alt="RobotC"></td>     
</tr> 
  <tr bgcolor="#cccc99" align="right"> 
          <td colspan=3> <font face="arial" size="-1"> [<a href=main.html>Home</a>] [<a target=_top href="https://sourceforge.net/projects/rdpartyrobotcdr/">Download</a>] [<a target=_top href="http://apps.sourceforge.net/mantisbt/rdpartyrobotcdr/my_view_page.php">Submit a bug/suggestion</a>]  [<a target=_top href="http://www.robotc.net/forums/">ROBOTC Forums</a>] [<a target=_top href="http://botbench.com">Blog</a>] [<a target=_top href="http://sourceforge.net/donate/index.php?group_id=257238">Support this project</a>]</font> </td> 
</tr> 
</table></td></tr> 
</table> 
<!-- Generated by Doxygen 1.7.2 -->
<div class="header">
  <div class="headertitle">
<h1>dexterind-imu.h</h1>  </div>
</div>
<div class="contents">
<a href="dexterind-imu_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*!@addtogroup Dexter_Industries</span>
<a name="l00002"></a>00002 <span class="comment"> * @{</span>
<a name="l00003"></a>00003 <span class="comment"> * @defgroup DIMU IMU Sensor</span>
<a name="l00004"></a>00004 <span class="comment"> * Dexter Industries DIMU Sensor driver</span>
<a name="l00005"></a>00005 <span class="comment"> * @{</span>
<a name="l00006"></a>00006 <span class="comment"> */</span>
<a name="l00007"></a>00007 
<a name="l00008"></a>00008 <span class="comment">/*</span>
<a name="l00009"></a>00009 <span class="comment"> * $Id: dexterind-imu.h 133 2013-03-10 15:15:38Z xander $</span>
<a name="l00010"></a>00010 <span class="comment"> */</span>
<a name="l00011"></a>00011 
<a name="l00012"></a>00012 <span class="preprocessor">#ifndef __DIMU_H__</span>
<a name="l00013"></a>00013 <span class="preprocessor"></span><span class="preprocessor">#define __DIMU_H__</span>
<a name="l00014"></a>00014 <span class="preprocessor"></span><span class="comment">/** \file dexterind-imu.h</span>
<a name="l00015"></a>00015 <span class="comment"> * \brief Dexter Industries IMU Sensor driver</span>
<a name="l00016"></a>00016 <span class="comment"> *</span>
<a name="l00017"></a>00017 <span class="comment"> * dexterind-imu.h provides an API for the Dexter Industries IMU Sensor.\n</span>
<a name="l00018"></a>00018 <span class="comment"> *</span>
<a name="l00019"></a>00019 <span class="comment"> * Changelog:</span>
<a name="l00020"></a>00020 <span class="comment"> * - 0.1: Initial release</span>
<a name="l00021"></a>00021 <span class="comment"> *</span>
<a name="l00022"></a>00022 <span class="comment"> * Credits:</span>
<a name="l00023"></a>00023 <span class="comment"> * - Big thanks to Dexter Industries for providing me with the hardware necessary to write and test this.</span>
<a name="l00024"></a>00024 <span class="comment"> *</span>
<a name="l00025"></a>00025 <span class="comment"> * License: You may use this code as you wish, provided you give credit where its due.</span>
<a name="l00026"></a>00026 <span class="comment"> *</span>
<a name="l00027"></a>00027 <span class="comment"> * THIS CODE WILL ONLY WORK WITH ROBOTC VERSION 3.59 AND HIGHER. </span>
<a name="l00028"></a>00028 <span class="comment"></span>
<a name="l00029"></a>00029 <span class="comment"> </span>
<a name="l00030"></a>00030 <span class="comment"> * \author Xander Soldaat (xander_at_botbench.com)</span>
<a name="l00031"></a>00031 <span class="comment"> * \date 07 August 2011</span>
<a name="l00032"></a>00032 <span class="comment"> * \version 0.1</span>
<a name="l00033"></a>00033 <span class="comment"> * \example dexterind-imu-test1.c</span>
<a name="l00034"></a>00034 <span class="comment"> * \example dexterind-imu-test2.c</span>
<a name="l00035"></a>00035 <span class="comment"> */</span>
<a name="l00036"></a>00036 
<a name="l00037"></a>00037 <span class="preprocessor">#pragma systemFile</span>
<a name="l00038"></a>00038 <span class="preprocessor"></span>
<a name="l00039"></a>00039 <span class="preprocessor">#ifndef __COMMON_H__</span>
<a name="l00040"></a>00040 <span class="preprocessor"></span><span class="preprocessor">#include &quot;<a class="code" href="common_8h.html" title="Commonly used functions used by drivers.">common.h</a>&quot;</span>
<a name="l00041"></a>00041 <span class="preprocessor">#endif</span>
<a name="l00042"></a>00042 <span class="preprocessor"></span>
<a name="l00043"></a>00043 <span class="comment">//#define STRUCT_CODE_ENABLED 1</span>
<a name="l00044"></a>00044 
<a name="l00045"></a>00045 <span class="preprocessor">#ifdef STRUCT_CODE_ENABLED</span>
<a name="l00046"></a>00046 <span class="preprocessor"></span><span class="preprocessor">#warn &quot;You have enabled experimental code!&quot;</span>
<a name="l00047"></a>00047 <span class="preprocessor"></span><span class="preprocessor">#endif</span>
<a name="l00048"></a>00048 <span class="preprocessor"></span>
<a name="l00049"></a><a class="code" href="group___d_i_m_u.html#ga23505e0f05d6c2e5892d010111007edd">00049</a> <span class="preprocessor">#define DIMU_GYRO_I2C_ADDR      0xD2  </span><span class="comment">/*!&lt; Gyro I2C address */</span>
<a name="l00050"></a>00050 
<a name="l00051"></a><a class="code" href="group___d_i_m_u.html#ga63cb5b9f8a25ce54dbd3fa3634a46333">00051</a> <span class="preprocessor">#define DIMU_GYRO_RANGE_250     0x00  </span><span class="comment">/*!&lt; 250 dps range */</span>
<a name="l00052"></a><a class="code" href="group___d_i_m_u.html#ga37417ffca147e84baeb5233b6ebd6081">00052</a> <span class="preprocessor">#define DIMU_GYRO_RANGE_500     0x10  </span><span class="comment">/*!&lt; 500 dps range */</span>
<a name="l00053"></a><a class="code" href="group___d_i_m_u.html#gac7893f5e3ca3ed1b8b7ce5e41a9ea9cd">00053</a> <span class="preprocessor">#define DIMU_GYRO_RANGE_2000    0x30  </span><span class="comment">/*!&lt; 2000 dps range */</span>
<a name="l00054"></a><a class="code" href="group___d_i_m_u.html#gae226ad04bfffc67111cf83c3e7f31e7b">00054</a> <span class="preprocessor">#define DIMU_CTRL4_BLOCKDATA    0x80</span>
<a name="l00055"></a>00055 <span class="preprocessor"></span>
<a name="l00056"></a><a class="code" href="group___d_i_m_u.html#gac784c892e42b04ab2543a5f98f57322d">00056</a> <span class="preprocessor">#define DIMU_GYRO_CTRL_REG1     0x20  </span><span class="comment">/*!&lt; CTRL_REG1 for Gyro */</span>
<a name="l00057"></a><a class="code" href="group___d_i_m_u.html#ga5489c8f619ba50cbf14780c9d307659f">00057</a> <span class="preprocessor">#define DIMU_GYRO_CTRL_REG2     0x21  </span><span class="comment">/*!&lt; CTRL_REG2 for Gyro */</span>
<a name="l00058"></a><a class="code" href="group___d_i_m_u.html#ga398639d7a669cc18b41ef3e658f14957">00058</a> <span class="preprocessor">#define DIMU_GYRO_CTRL_REG3     0x22  </span><span class="comment">/*!&lt; CTRL_REG3 for Gyro */</span>
<a name="l00059"></a><a class="code" href="group___d_i_m_u.html#gab89482d8076471665dfa28d9d26d8bd0">00059</a> <span class="preprocessor">#define DIMU_GYRO_CTRL_REG4     0x23  </span><span class="comment">/*!&lt; CTRL_REG4 for Gyro */</span>
<a name="l00060"></a><a class="code" href="group___d_i_m_u.html#ga42de6d011cc592df664b6ebe3cb55a2d">00060</a> <span class="preprocessor">#define DIMU_GYRO_CTRL_REG5     0x24  </span><span class="comment">/*!&lt; CTRL_REG5 for Gyro */</span>
<a name="l00061"></a>00061 
<a name="l00062"></a><a class="code" href="group___d_i_m_u.html#gafd1737e32af944d6126243e81a1b157a">00062</a> <span class="preprocessor">#define DIMU_GYRO_ALL_AXES      0x28  </span><span class="comment">/*!&lt; All Axes for Gyro */</span>
<a name="l00063"></a><a class="code" href="group___d_i_m_u.html#gaf0d2432a131ce2e3bdf43e0f074a199c">00063</a> <span class="preprocessor">#define DIMU_GYRO_X_AXIS        0x2A  </span><span class="comment">/*!&lt; X Axis for Gyro */</span>
<a name="l00064"></a><a class="code" href="group___d_i_m_u.html#gaf3db5499646831e6c034e20b7f2e9b16">00064</a> <span class="preprocessor">#define DIMU_GYRO_Y_AXIS        0x28  </span><span class="comment">/*!&lt; Y Axis for Gyro */</span>
<a name="l00065"></a><a class="code" href="group___d_i_m_u.html#ga36fbdad69561a2335835343a69ce850c">00065</a> <span class="preprocessor">#define DIMU_GYRO_Z_AXIS        0x2C  </span><span class="comment">/*!&lt; Z Axis for Gyro */</span>
<a name="l00066"></a>00066 
<a name="l00067"></a><a class="code" href="group___d_i_m_u.html#ga35133720231204e0878da5ab26009294">00067</a> <span class="preprocessor">#define DIMU_ACC_I2C_ADDR       0x3A  </span><span class="comment">/*!&lt; Accelerometer I2C address */</span>
<a name="l00068"></a><a class="code" href="group___d_i_m_u.html#ga301e1ce2d9909389cfc690077187f5df">00068</a> <span class="preprocessor">#define DIMU_ACC_RANGE_2G       0x04  </span><span class="comment">/*!&lt; Accelerometer 2G range */</span>
<a name="l00069"></a><a class="code" href="group___d_i_m_u.html#gadf80583ef8625d74748250cf18e2acfb">00069</a> <span class="preprocessor">#define DIMU_ACC_RANGE_4G       0x08  </span><span class="comment">/*!&lt; Accelerometer 4G range */</span>
<a name="l00070"></a><a class="code" href="group___d_i_m_u.html#ga0028d43b1db87a0aacd4cb7566a805b4">00070</a> <span class="preprocessor">#define DIMU_ACC_RANGE_8G       0x00  </span><span class="comment">/*!&lt; Accelerometer 8G range */</span>
<a name="l00071"></a><a class="code" href="group___d_i_m_u.html#ga9d61981ed3270b976aa5c05bdec1cc8c">00071</a> <span class="preprocessor">#define DIMU_ACC_MODE_STBY      0x00  </span><span class="comment">/*!&lt; Accelerometer standby mode */</span>
<a name="l00072"></a><a class="code" href="group___d_i_m_u.html#ga63a1a5092f122b4cb5209ec9a3cf11bd">00072</a> <span class="preprocessor">#define DIMU_ACC_MODE_MEAS      0x01  </span><span class="comment">/*!&lt; Accelerometer measurement mode */</span>
<a name="l00073"></a><a class="code" href="group___d_i_m_u.html#gad0fe41dcf96024cf5f6eca93c0755ce9">00073</a> <span class="preprocessor">#define DIMU_ACC_MODE_LVLD      0x02  </span><span class="comment">/*!&lt; Accelerometer level detect mode */</span>
<a name="l00074"></a><a class="code" href="group___d_i_m_u.html#ga819110e1ad921c28bba403033d2ab72a">00074</a> <span class="preprocessor">#define DIMU_ACC_MODE_PLSE      0x03  </span><span class="comment">/*!&lt; Accelerometer pulse detect mode */</span>
<a name="l00075"></a><a class="code" href="group___d_i_m_u.html#gaf85e1b013649f1a48dada5377dd37539">00075</a> <span class="preprocessor">#define DIMU_ACC_X_AXIS         0x00  </span><span class="comment">/*!&lt; X Axis for Accel */</span>
<a name="l00076"></a><a class="code" href="group___d_i_m_u.html#ga848aedcc8dccf9afaf4b4e122adcfdd1">00076</a> <span class="preprocessor">#define DIMU_ACC_Y_AXIS         0x02  </span><span class="comment">/*!&lt; Y Axis for Accel */</span>
<a name="l00077"></a><a class="code" href="group___d_i_m_u.html#gaf1a0ef415e159c87a8a022ed1259e052">00077</a> <span class="preprocessor">#define DIMU_ACC_Z_AXIS         0x04  </span><span class="comment">/*!&lt; Z Axis for Accel */</span>
<a name="l00078"></a>00078 
<a name="l00079"></a><a class="code" href="group___d_i_m_u.html#gadf1c5b1a0eb1523f0548e191fb835f02">00079</a> <span class="preprocessor">#define DIMUreadGyroXAxis(X) DIMUreadGyroAxis(X, DIMU_GYRO_X_AXIS)</span>
<a name="l00080"></a><a class="code" href="group___d_i_m_u.html#ga5066e2caf7d45d53ed96c9329960c20c">00080</a> <span class="preprocessor"></span><span class="preprocessor">#define DIMUreadGyroYAxis(X) DIMUreadGyroAxis(X, DIMU_GYRO_Y_AXIS)</span>
<a name="l00081"></a><a class="code" href="group___d_i_m_u.html#gaa595a49b3fc848e1c5c22ef2e9bfbaa9">00081</a> <span class="preprocessor"></span><span class="preprocessor">#define DIMUreadGyroZAxis(X) DIMUreadGyroAxis(X, DIMU_GYRO_Z_AXIS)</span>
<a name="l00082"></a>00082 <span class="preprocessor"></span>
<a name="l00083"></a><a class="code" href="group___d_i_m_u.html#ga2d654fb32431876ae10186ddca54851c">00083</a> <span class="preprocessor">#define DIMUreadAccelXAxis10Bit(X) DIMUreadAccelAxis10Bit(X, DIMU_ACC_X_AXIS)</span>
<a name="l00084"></a><a class="code" href="group___d_i_m_u.html#ga96cc7c722e6b3877c8e573b29772372f">00084</a> <span class="preprocessor"></span><span class="preprocessor">#define DIMUreadAccelYAxis10Bit(X) DIMUreadAccelAxis10Bit(X, DIMU_ACC_Y_AXIS)</span>
<a name="l00085"></a><a class="code" href="group___d_i_m_u.html#gacb02dc7a41e625086547d1252509140f">00085</a> <span class="preprocessor"></span><span class="preprocessor">#define DIMUreadAccelZAxis10Bit(X) DIMUreadAccelAxis10Bit(X, DIMU_ACC_Z_AXIS)</span>
<a name="l00086"></a>00086 <span class="preprocessor"></span>
<a name="l00087"></a><a class="code" href="group___d_i_m_u.html#gaf5cf0eb8441d4c4cbfaa6807fdad00df">00087</a> <span class="preprocessor">#define DIMUreadAccelXAxis8Bit(X) DIMUreadAccelAxis8Bit(X, DIMU_ACC_X_AXIS)</span>
<a name="l00088"></a><a class="code" href="group___d_i_m_u.html#ga9d2389a6715d411b3f0c4438b66b05cb">00088</a> <span class="preprocessor"></span><span class="preprocessor">#define DIMUreadAccelYAxis8Bit(X) DIMUreadAccelAxis8Bit(X, DIMU_ACC_Y_AXIS)</span>
<a name="l00089"></a><a class="code" href="group___d_i_m_u.html#ga4272054c4dcd75bcaa580596f10c71da">00089</a> <span class="preprocessor"></span><span class="preprocessor">#define DIMUreadAccelZAxis8Bit(X) DIMUreadAccelAxis8Bit(X, DIMU_ACC_Z_AXIS)</span>
<a name="l00090"></a>00090 <span class="preprocessor"></span>
<a name="l00091"></a>00091 <span class="comment">// for future use</span>
<a name="l00092"></a>00092 <span class="preprocessor">#ifdef STRUCT_CODE_ENABLED</span>
<a name="l00093"></a>00093 <span class="preprocessor"></span><span class="keyword">typedef</span> <span class="keyword">struct</span>
<a name="l00094"></a>00094 {
<a name="l00095"></a>00095   ubyte I2CAddress;
<a name="l00096"></a>00096   tSensors link;
<a name="l00097"></a>00097   <a class="code" href="group__common.html#gaa172ef131853460e5b9f5c6db81d30f4">tByteArray</a> I2CRequest;
<a name="l00098"></a>00098   <a class="code" href="group__common.html#gaa172ef131853460e5b9f5c6db81d30f4">tByteArray</a> I2CReply;
<a name="l00099"></a>00099   <span class="keywordtype">float</span> gyroDivisor;
<a name="l00100"></a>00100   <span class="keywordtype">float</span> accelDivisor;
<a name="l00101"></a>00101   <span class="keywordtype">float</span> axesAccel8Bit[3];
<a name="l00102"></a>00102   <span class="keywordtype">float</span> axesAccel10Bit[3];
<a name="l00103"></a>00103   <span class="keywordtype">float</span> axesGyro8Bit[3];
<a name="l00104"></a>00104   <span class="keywordtype">float</span> axesGyro10Bit[3];
<a name="l00105"></a>00105 } tDIMUdata, *tDIMUdataPtr;
<a name="l00106"></a>00106 <span class="preprocessor">#endif</span>
<a name="l00107"></a>00107 <span class="preprocessor"></span>
<a name="l00108"></a><a class="code" href="group___d_i_m_u.html#ga6f1c4ca2d865d44c5263abb502045c62">00108</a> <span class="keywordtype">float</span> <a class="code" href="group___d_i_m_u.html#ga6f1c4ca2d865d44c5263abb502045c62">DIMU_Gyro_divisor</a>[4] = {0.0, 0.0, 0.0, 0.0}; <span class="comment">/*!&lt; Array to hold divisor data for 8 bit measurements */</span>
<a name="l00109"></a><a class="code" href="group___d_i_m_u.html#ga2b0a038cf853ef2c9f46494964930c34">00109</a> <span class="keywordtype">float</span> <a class="code" href="group___d_i_m_u.html#ga2b0a038cf853ef2c9f46494964930c34">DIMU_Accel_divisor</a>[4] = {0.0, 0.0, 0.0, 0.0}; <span class="comment">/*!&lt; Array to hold divisor data for 8 bit measurements */</span>
<a name="l00110"></a>00110 
<a name="l00111"></a><a class="code" href="group___d_i_m_u.html#gadfc6982370af0cb2087e84ad04d99ed3">00111</a> <a class="code" href="group__common.html#gaa172ef131853460e5b9f5c6db81d30f4">tByteArray</a> <a class="code" href="group___d_i_m_u.html#gadfc6982370af0cb2087e84ad04d99ed3">DIMU_I2CRequest</a>;    <span class="comment">/*!&lt; Array to hold I2C command data */</span>
<a name="l00112"></a><a class="code" href="group___d_i_m_u.html#gad1f318719870a6a10e1a86596247d7a5">00112</a> <a class="code" href="group__common.html#gaa172ef131853460e5b9f5c6db81d30f4">tByteArray</a> <a class="code" href="group___d_i_m_u.html#gad1f318719870a6a10e1a86596247d7a5">DIMU_I2CReply</a>;      <span class="comment">/*!&lt; Array to hold I2C reply data */</span>
<a name="l00113"></a>00113 
<a name="l00114"></a>00114 
<a name="l00115"></a>00115 <span class="keywordtype">bool</span> <a class="code" href="group___d_i_m_u.html#ga6e9ba4ee66fd46ccf2bc506870289034">DIMUconfigGyro</a>(tSensors link, ubyte range, <span class="keywordtype">bool</span> lpfenable=<span class="keyword">true</span>);
<a name="l00116"></a>00116 <span class="keywordtype">float</span> <a class="code" href="group___d_i_m_u.html#ga9a46c80c14526740a385de9706c54d88">DIMUreadGyroAxis</a>(tSensors link, ubyte axis);
<a name="l00117"></a>00117 <span class="keywordtype">void</span> <a class="code" href="group___d_i_m_u.html#gab827ec900619ac00a404286787bd4374">DIMUreadGyroAxes</a>(tSensors link, <span class="keywordtype">float</span> &amp;_x, <span class="keywordtype">float</span> &amp;_y, <span class="keywordtype">float</span> &amp;_z);
<a name="l00118"></a>00118 <span class="keywordtype">bool</span> <a class="code" href="group___d_i_m_u.html#gae23d7e3cdc85d3113a302cb094c2746c">DIMUconfigAccel</a>(tSensors link, ubyte range);
<a name="l00119"></a>00119 <span class="keywordtype">float</span> <a class="code" href="group___d_i_m_u.html#ga89c00817a8f7463845fe5bb995104cb8">DIMUreadAccelAxis8Bit</a>(tSensors link, ubyte axis);
<a name="l00120"></a>00120 <span class="keywordtype">bool</span> <a class="code" href="group___d_i_m_u.html#ga4ad63971c9ff9771f43e29183fcde431">DIMUsetAccelAxisOffset</a>(tSensors link, ubyte drift_reg, ubyte drift_LSB, ubyte drift_MSB);
<a name="l00121"></a>00121 <span class="keywordtype">float</span> <a class="code" href="group___d_i_m_u.html#ga5a776ba768845791ae8f4ebc68bb7f61">DIMUreadAccelAxis10Bit</a>(tSensors link, ubyte axis, <span class="keywordtype">bool</span> calibrate = <span class="keyword">false</span>);
<a name="l00122"></a>00122 <span class="keywordtype">void</span> <a class="code" href="group___d_i_m_u.html#ga4fa39ada897e8334bec22b358db89d46">DIMUreadAccelAxes8Bit</a>(tSensors link, <span class="keywordtype">float</span> &amp;_x, <span class="keywordtype">float</span> &amp;_y, <span class="keywordtype">float</span> &amp;_z);
<a name="l00123"></a>00123 <span class="keywordtype">void</span> <a class="code" href="group___d_i_m_u.html#ga3b19a2fa3659abefee9df342291e4527">DIMUreadAccelAxes10Bit</a>(tSensors link, <span class="keywordtype">float</span> &amp;_x, <span class="keywordtype">float</span> &amp;_y, <span class="keywordtype">float</span> &amp;_z);
<a name="l00124"></a>00124 <span class="keywordtype">void</span> <a class="code" href="group___d_i_m_u.html#gae9e0c26bd535cfd590f93b9b28d4230b">DIMUcalAccel</a>(tSensors link);
<a name="l00125"></a>00125 <span class="keywordtype">bool</span> <a class="code" href="group___d_i_m_u.html#ga3c0d3332e0fb25fc3a271733ea577a49">DIMUconfigIMU</a>(tSensors link, ubyte accelRange=<a class="code" href="group___d_i_m_u.html#ga0028d43b1db87a0aacd4cb7566a805b4">DIMU_ACC_RANGE_8G</a>, ubyte gyroRange=<a class="code" href="group___d_i_m_u.html#ga63cb5b9f8a25ce54dbd3fa3634a46333">DIMU_GYRO_RANGE_250</a>, <span class="keywordtype">bool</span> lpfenable=<span class="keyword">true</span>);
<a name="l00126"></a>00126 
<a name="l00127"></a>00127 <span class="preprocessor">#ifdef STRUCT_CODE_ENABLED</span>
<a name="l00128"></a>00128 <span class="preprocessor"></span><span class="keywordtype">bool</span> <a class="code" href="group___d_i_m_u.html#ga6e9ba4ee66fd46ccf2bc506870289034">DIMUconfigGyro</a>(tDIMUdataPtr sensor, ubyte range, <span class="keywordtype">bool</span> lpfenable=<span class="keyword">true</span>);
<a name="l00129"></a>00129 <span class="keywordtype">void</span> <a class="code" href="group___d_i_m_u.html#gab827ec900619ac00a404286787bd4374">DIMUreadGyroAxes</a>(tDIMUdataPtr sensor);
<a name="l00130"></a>00130 <span class="keywordtype">bool</span> <a class="code" href="group___d_i_m_u.html#gae23d7e3cdc85d3113a302cb094c2746c">DIMUconfigAccel</a>(tDIMUdataPtr sensor, ubyte range);
<a name="l00131"></a>00131 <span class="keywordtype">void</span> <a class="code" href="group___d_i_m_u.html#ga4fa39ada897e8334bec22b358db89d46">DIMUreadAccelAxes8Bit</a>(tDIMUdataPtr sensor);
<a name="l00132"></a>00132 <span class="keywordtype">void</span> <a class="code" href="group___d_i_m_u.html#ga3b19a2fa3659abefee9df342291e4527">DIMUreadAccelAxes10Bit</a>(tDIMUdataPtr sensor);
<a name="l00133"></a>00133 <span class="keywordtype">void</span> <a class="code" href="group___d_i_m_u.html#gae9e0c26bd535cfd590f93b9b28d4230b">DIMUcalAccel</a>(tDIMUdataPtr sensor);
<a name="l00134"></a>00134 <span class="keywordtype">bool</span> <a class="code" href="group___d_i_m_u.html#ga3c0d3332e0fb25fc3a271733ea577a49">DIMUconfigIMU</a>(tDIMUdataPtr sensor, ubyte accelRange=<a class="code" href="group___d_i_m_u.html#ga0028d43b1db87a0aacd4cb7566a805b4">DIMU_ACC_RANGE_8G</a>, ubyte gyroRange=<a class="code" href="group___d_i_m_u.html#ga63cb5b9f8a25ce54dbd3fa3634a46333">DIMU_GYRO_RANGE_250</a>, <span class="keywordtype">bool</span> lpfenable=<span class="keyword">true</span>);
<a name="l00135"></a>00135 <span class="preprocessor">#endif</span>
<a name="l00136"></a>00136 <span class="preprocessor"></span><span class="comment"></span>
<a name="l00137"></a>00137 <span class="comment">/**</span>
<a name="l00138"></a>00138 <span class="comment"> * Configure the gyro</span>
<a name="l00139"></a>00139 <span class="comment"> * @param link the port number</span>
<a name="l00140"></a>00140 <span class="comment"> * @param range the operating range of the gyro</span>
<a name="l00141"></a>00141 <span class="comment"> * @param lpfenable Enable built-in Low Pass Filter to reduce spikes in data, optional, defaults to true.</span>
<a name="l00142"></a>00142 <span class="comment"> * @return true if no error occured, false if it did</span>
<a name="l00143"></a>00143 <span class="comment"> */</span>
<a name="l00144"></a><a class="code" href="group___d_i_m_u.html#ga6e9ba4ee66fd46ccf2bc506870289034">00144</a> <span class="keywordtype">bool</span> <a class="code" href="group___d_i_m_u.html#ga6e9ba4ee66fd46ccf2bc506870289034">DIMUconfigGyro</a>(tSensors link, ubyte range, <span class="keywordtype">bool</span> lpfenable){
<a name="l00145"></a>00145         memset(<a class="code" href="group___d_i_m_u.html#gadfc6982370af0cb2087e84ad04d99ed3">DIMU_I2CRequest</a>, 0, <span class="keyword">sizeof</span>(<a class="code" href="group___d_i_m_u.html#gadfc6982370af0cb2087e84ad04d99ed3">DIMU_I2CRequest</a>));
<a name="l00146"></a>00146 
<a name="l00147"></a>00147         <span class="comment">// Setup the size and address, same for all requests.</span>
<a name="l00148"></a>00148         <a class="code" href="group___d_i_m_u.html#gadfc6982370af0cb2087e84ad04d99ed3">DIMU_I2CRequest</a>[0] = 3;    <span class="comment">// Sending address, register, value. Optional, defaults to true</span>
<a name="l00149"></a>00149         <a class="code" href="group___d_i_m_u.html#gadfc6982370af0cb2087e84ad04d99ed3">DIMU_I2CRequest</a>[1] = 0xD2; <span class="comment">// I2C Address of gyro.</span>
<a name="l00150"></a>00150 
<a name="l00151"></a>00151         <span class="comment">// Write CTRL_REG2</span>
<a name="l00152"></a>00152         <span class="comment">// No High Pass Filter</span>
<a name="l00153"></a>00153         <a class="code" href="group___d_i_m_u.html#gadfc6982370af0cb2087e84ad04d99ed3">DIMU_I2CRequest</a>[2] = <a class="code" href="group___d_i_m_u.html#ga5489c8f619ba50cbf14780c9d307659f">DIMU_GYRO_CTRL_REG2</a>;
<a name="l00154"></a>00154         <a class="code" href="group___d_i_m_u.html#gadfc6982370af0cb2087e84ad04d99ed3">DIMU_I2CRequest</a>[3] = 0x00;
<a name="l00155"></a>00155         <span class="keywordflow">if</span> (!<a class="code" href="group__common.html#gad02e06f83b264ee6fc7df41eb4712080">writeI2C</a>(link, <a class="code" href="group___d_i_m_u.html#gadfc6982370af0cb2087e84ad04d99ed3">DIMU_I2CRequest</a>))
<a name="l00156"></a>00156           <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00157"></a>00157 
<a name="l00158"></a>00158         <span class="comment">// Write CTRL_REG3</span>
<a name="l00159"></a>00159         <span class="comment">// No interrupts.  Date ready.</span><span class="comment"></span>
<a name="l00160"></a>00160 <span class="comment">        ////////////////////////////////////////////////////////////////////////////</span>
<a name="l00161"></a>00161 <span class="comment"></span>        <a class="code" href="group___d_i_m_u.html#gadfc6982370af0cb2087e84ad04d99ed3">DIMU_I2CRequest</a>[2] = <a class="code" href="group___d_i_m_u.html#ga398639d7a669cc18b41ef3e658f14957">DIMU_GYRO_CTRL_REG3</a>;      <span class="comment">// Register address of CTRL_REG3</span>
<a name="l00162"></a>00162         <a class="code" href="group___d_i_m_u.html#gadfc6982370af0cb2087e84ad04d99ed3">DIMU_I2CRequest</a>[3] = 0x08;      <span class="comment">// No interrupts.  Date ready.</span>
<a name="l00163"></a>00163         <span class="keywordflow">if</span>(!<a class="code" href="group__common.html#gad02e06f83b264ee6fc7df41eb4712080">writeI2C</a>(link, <a class="code" href="group___d_i_m_u.html#gadfc6982370af0cb2087e84ad04d99ed3">DIMU_I2CRequest</a>))
<a name="l00164"></a>00164           <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00165"></a>00165 
<a name="l00166"></a>00166         <span class="comment">// Write CTRL_REG4</span>
<a name="l00167"></a>00167         <span class="comment">// Full scale range.</span>
<a name="l00168"></a>00168         <a class="code" href="group___d_i_m_u.html#gadfc6982370af0cb2087e84ad04d99ed3">DIMU_I2CRequest</a>[2] = <a class="code" href="group___d_i_m_u.html#gab89482d8076471665dfa28d9d26d8bd0">DIMU_GYRO_CTRL_REG4</a>;
<a name="l00169"></a>00169         <a class="code" href="group___d_i_m_u.html#gadfc6982370af0cb2087e84ad04d99ed3">DIMU_I2CRequest</a>[3] = range + <a class="code" href="group___d_i_m_u.html#gae226ad04bfffc67111cf83c3e7f31e7b">DIMU_CTRL4_BLOCKDATA</a>;
<a name="l00170"></a>00170         <a class="code" href="group__common.html#gad02e06f83b264ee6fc7df41eb4712080">writeI2C</a>(link, <a class="code" href="group___d_i_m_u.html#gadfc6982370af0cb2087e84ad04d99ed3">DIMU_I2CRequest</a>);
<a name="l00171"></a>00171 
<a name="l00172"></a>00172         <span class="comment">//Write CTRL_REG5</span>
<a name="l00173"></a>00173         <a class="code" href="group___d_i_m_u.html#gadfc6982370af0cb2087e84ad04d99ed3">DIMU_I2CRequest</a>[2] = <a class="code" href="group___d_i_m_u.html#ga42de6d011cc592df664b6ebe3cb55a2d">DIMU_GYRO_CTRL_REG5</a>;      <span class="comment">// Register address of CTRL_REG5</span>
<a name="l00174"></a>00174         <a class="code" href="group___d_i_m_u.html#gadfc6982370af0cb2087e84ad04d99ed3">DIMU_I2CRequest</a>[3] = (lpfenable) ? 0x02 : 0x00;      <span class="comment">// filtering - low pass</span>
<a name="l00175"></a>00175         <span class="keywordflow">if</span> (!<a class="code" href="group__common.html#gad02e06f83b264ee6fc7df41eb4712080">writeI2C</a>(link, <a class="code" href="group___d_i_m_u.html#gadfc6982370af0cb2087e84ad04d99ed3">DIMU_I2CRequest</a>))
<a name="l00176"></a>00176           <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00177"></a>00177 
<a name="l00178"></a>00178         <span class="comment">// Write CTRL_REG1</span>
<a name="l00179"></a>00179         <span class="comment">// Enable all axes. Disable power down.</span>
<a name="l00180"></a>00180         <a class="code" href="group___d_i_m_u.html#gadfc6982370af0cb2087e84ad04d99ed3">DIMU_I2CRequest</a>[2] = <a class="code" href="group___d_i_m_u.html#gac784c892e42b04ab2543a5f98f57322d">DIMU_GYRO_CTRL_REG1</a>;
<a name="l00181"></a>00181         <a class="code" href="group___d_i_m_u.html#gadfc6982370af0cb2087e84ad04d99ed3">DIMU_I2CRequest</a>[3] = 0x0F;
<a name="l00182"></a>00182         <span class="keywordflow">if</span> (!<a class="code" href="group__common.html#gad02e06f83b264ee6fc7df41eb4712080">writeI2C</a>(link, <a class="code" href="group___d_i_m_u.html#gadfc6982370af0cb2087e84ad04d99ed3">DIMU_I2CRequest</a>))
<a name="l00183"></a>00183           <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00184"></a>00184 
<a name="l00185"></a>00185         <span class="comment">// Set DIMU_Gyro_divisor so that the output of our gyro axis readings can be turned</span>
<a name="l00186"></a>00186         <span class="comment">// into scaled values.</span><span class="comment"></span>
<a name="l00187"></a>00187 <span class="comment">        ///////////////////////////////////////////////////////////////////////////</span>
<a name="l00188"></a>00188 <span class="comment"></span>        <span class="keywordflow">if</span>(range == 0)
<a name="l00189"></a>00189           <a class="code" href="group___d_i_m_u.html#ga6f1c4ca2d865d44c5263abb502045c62">DIMU_Gyro_divisor</a>[link] = 114.28571;      <span class="comment">// Full scale range is 250 dps.</span>
<a name="l00190"></a>00190   <span class="keywordflow">else</span> <span class="keywordflow">if</span> (range == 0x10)
<a name="l00191"></a>00191     <a class="code" href="group___d_i_m_u.html#ga6f1c4ca2d865d44c5263abb502045c62">DIMU_Gyro_divisor</a>[link] = 57.142857;       <span class="comment">// Full scale range is 500 dps.</span>
<a name="l00192"></a>00192         <span class="keywordflow">else</span> <span class="keywordflow">if</span> (range == 0x30)
<a name="l00193"></a>00193           <a class="code" href="group___d_i_m_u.html#ga6f1c4ca2d865d44c5263abb502045c62">DIMU_Gyro_divisor</a>[link] = 14.285714;       <span class="comment">// Full scale range is 2000 dps.</span>
<a name="l00194"></a>00194 
<a name="l00195"></a>00195         <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00196"></a>00196 }
<a name="l00197"></a>00197 
<a name="l00198"></a>00198 <span class="comment"></span>
<a name="l00199"></a>00199 <span class="comment">/**</span>
<a name="l00200"></a>00200 <span class="comment"> * Retrieve the axis data</span>
<a name="l00201"></a>00201 <span class="comment"> * @param link the port number</span>
<a name="l00202"></a>00202 <span class="comment"> * @param axis the specified axis</span>
<a name="l00203"></a>00203 <span class="comment"> * @return the axis data in degrees per second</span>
<a name="l00204"></a>00204 <span class="comment"> */</span>
<a name="l00205"></a><a class="code" href="group___d_i_m_u.html#ga9a46c80c14526740a385de9706c54d88">00205</a> <span class="keywordtype">float</span> <a class="code" href="group___d_i_m_u.html#ga9a46c80c14526740a385de9706c54d88">DIMUreadGyroAxis</a>(tSensors link, ubyte axis){
<a name="l00206"></a>00206         <span class="comment">// ubyte _msb = 0;</span>
<a name="l00207"></a>00207         <span class="comment">// ubyte _lsb = 0;</span>
<a name="l00208"></a>00208 
<a name="l00209"></a>00209         <a class="code" href="group___d_i_m_u.html#gadfc6982370af0cb2087e84ad04d99ed3">DIMU_I2CRequest</a>[0] = 2;                   <span class="comment">// Message size</span>
<a name="l00210"></a>00210   <a class="code" href="group___d_i_m_u.html#gadfc6982370af0cb2087e84ad04d99ed3">DIMU_I2CRequest</a>[1] = <a class="code" href="group___d_i_m_u.html#ga23505e0f05d6c2e5892d010111007edd">DIMU_GYRO_I2C_ADDR</a>;  <span class="comment">// I2C Address</span>
<a name="l00211"></a>00211         <a class="code" href="group___d_i_m_u.html#gadfc6982370af0cb2087e84ad04d99ed3">DIMU_I2CRequest</a>[2] = axis + 0x80;            <span class="comment">// Register address</span>
<a name="l00212"></a>00212 
<a name="l00213"></a>00213   <span class="keywordflow">if</span> (!<a class="code" href="group__common.html#gad02e06f83b264ee6fc7df41eb4712080">writeI2C</a>(link, <a class="code" href="group___d_i_m_u.html#gadfc6982370af0cb2087e84ad04d99ed3">DIMU_I2CRequest</a>, <a class="code" href="group___d_i_m_u.html#gad1f318719870a6a10e1a86596247d7a5">DIMU_I2CReply</a>, 2)) {
<a name="l00214"></a>00214     writeDebugStreamLine(<span class="stringliteral">&quot;error write&quot;</span>);
<a name="l00215"></a>00215     <span class="keywordflow">return</span> 0;
<a name="l00216"></a>00216   }
<a name="l00217"></a>00217 
<a name="l00218"></a>00218   <span class="keywordflow">return</span> (<a class="code" href="group___d_i_m_u.html#gad1f318719870a6a10e1a86596247d7a5">DIMU_I2CReply</a>[0]+((<span class="keywordtype">long</span>)(<a class="code" href="group___d_i_m_u.html#gad1f318719870a6a10e1a86596247d7a5">DIMU_I2CReply</a>[1]&lt;&lt;8)))/<a class="code" href="group___d_i_m_u.html#ga6f1c4ca2d865d44c5263abb502045c62">DIMU_Gyro_divisor</a>[link];
<a name="l00219"></a>00219 }
<a name="l00220"></a>00220 
<a name="l00221"></a>00221 <span class="comment"></span>
<a name="l00222"></a>00222 <span class="comment">/**</span>
<a name="l00223"></a>00223 <span class="comment"> * Read all three axes of the gyro</span>
<a name="l00224"></a>00224 <span class="comment"> * @param link the port number</span>
<a name="l00225"></a>00225 <span class="comment"> * @param _x data for x axis in degrees per second</span>
<a name="l00226"></a>00226 <span class="comment"> * @param _y data for y axis in degrees per second</span>
<a name="l00227"></a>00227 <span class="comment"> * @param _z data for z axis in degrees per second</span>
<a name="l00228"></a>00228 <span class="comment"> * @return true if no error occured, false if it did</span>
<a name="l00229"></a>00229 <span class="comment"> */</span>
<a name="l00230"></a><a class="code" href="group___d_i_m_u.html#gab827ec900619ac00a404286787bd4374">00230</a> <span class="keywordtype">void</span> <a class="code" href="group___d_i_m_u.html#gab827ec900619ac00a404286787bd4374">DIMUreadGyroAxes</a>(tSensors link, <span class="keywordtype">float</span> &amp;_x, <span class="keywordtype">float</span> &amp;_y, <span class="keywordtype">float</span> &amp;_z){
<a name="l00231"></a>00231         <a class="code" href="group___d_i_m_u.html#gadfc6982370af0cb2087e84ad04d99ed3">DIMU_I2CRequest</a>[0] = 2;                   <span class="comment">// Message size</span>
<a name="l00232"></a>00232   <a class="code" href="group___d_i_m_u.html#gadfc6982370af0cb2087e84ad04d99ed3">DIMU_I2CRequest</a>[1] = <a class="code" href="group___d_i_m_u.html#ga23505e0f05d6c2e5892d010111007edd">DIMU_GYRO_I2C_ADDR</a>;  <span class="comment">// I2C Address</span>
<a name="l00233"></a>00233         <a class="code" href="group___d_i_m_u.html#gadfc6982370af0cb2087e84ad04d99ed3">DIMU_I2CRequest</a>[2] = <a class="code" href="group___d_i_m_u.html#gafd1737e32af944d6126243e81a1b157a">DIMU_GYRO_ALL_AXES</a> + 0x80;            <span class="comment">// Register address</span>
<a name="l00234"></a>00234 
<a name="l00235"></a>00235   <span class="keywordflow">if</span> (!<a class="code" href="group__common.html#gad02e06f83b264ee6fc7df41eb4712080">writeI2C</a>(link, <a class="code" href="group___d_i_m_u.html#gadfc6982370af0cb2087e84ad04d99ed3">DIMU_I2CRequest</a>, <a class="code" href="group___d_i_m_u.html#gad1f318719870a6a10e1a86596247d7a5">DIMU_I2CReply</a>, 6)) {
<a name="l00236"></a>00236     writeDebugStreamLine(<span class="stringliteral">&quot;error write&quot;</span>);
<a name="l00237"></a>00237     <span class="keywordflow">return</span>;
<a name="l00238"></a>00238   }
<a name="l00239"></a>00239 
<a name="l00240"></a>00240   _y = (<a class="code" href="group___d_i_m_u.html#gad1f318719870a6a10e1a86596247d7a5">DIMU_I2CReply</a>[0]+((long)(<a class="code" href="group___d_i_m_u.html#gad1f318719870a6a10e1a86596247d7a5">DIMU_I2CReply</a>[1]&lt;&lt;8)))/<a class="code" href="group___d_i_m_u.html#ga6f1c4ca2d865d44c5263abb502045c62">DIMU_Gyro_divisor</a>[link];
<a name="l00241"></a>00241   _x = (<a class="code" href="group___d_i_m_u.html#gad1f318719870a6a10e1a86596247d7a5">DIMU_I2CReply</a>[2]+((long)(<a class="code" href="group___d_i_m_u.html#gad1f318719870a6a10e1a86596247d7a5">DIMU_I2CReply</a>[3]&lt;&lt;8)))/<a class="code" href="group___d_i_m_u.html#ga6f1c4ca2d865d44c5263abb502045c62">DIMU_Gyro_divisor</a>[link];
<a name="l00242"></a>00242   _z = (<a class="code" href="group___d_i_m_u.html#gad1f318719870a6a10e1a86596247d7a5">DIMU_I2CReply</a>[4]+((long)(<a class="code" href="group___d_i_m_u.html#gad1f318719870a6a10e1a86596247d7a5">DIMU_I2CReply</a>[5]&lt;&lt;8)))/<a class="code" href="group___d_i_m_u.html#ga6f1c4ca2d865d44c5263abb502045c62">DIMU_Gyro_divisor</a>[link];
<a name="l00243"></a>00243 }
<a name="l00244"></a>00244 
<a name="l00245"></a>00245 <span class="comment"></span>
<a name="l00246"></a>00246 <span class="comment">/**</span>
<a name="l00247"></a>00247 <span class="comment"> * Wait for the I2C bus to be ready for the next message</span>
<a name="l00248"></a>00248 <span class="comment"> * @param link the port number</span>
<a name="l00249"></a>00249 <span class="comment"> * @param range the range at which to operate the Accelerometer, can be 2, 4 and 8G</span>
<a name="l00250"></a>00250 <span class="comment"> * @return true if no error occured, false if it did</span>
<a name="l00251"></a>00251 <span class="comment"> */</span>
<a name="l00252"></a><a class="code" href="group___d_i_m_u.html#gae23d7e3cdc85d3113a302cb094c2746c">00252</a> <span class="keywordtype">bool</span> <a class="code" href="group___d_i_m_u.html#gae23d7e3cdc85d3113a302cb094c2746c">DIMUconfigAccel</a>(tSensors link, ubyte range) {
<a name="l00253"></a>00253   <span class="keywordflow">switch</span>(range) {
<a name="l00254"></a>00254     <span class="keywordflow">case</span> <a class="code" href="group___d_i_m_u.html#ga301e1ce2d9909389cfc690077187f5df">DIMU_ACC_RANGE_2G</a>: <a class="code" href="group___d_i_m_u.html#ga2b0a038cf853ef2c9f46494964930c34">DIMU_Accel_divisor</a>[link] = 64.0; <span class="keywordflow">break</span>;
<a name="l00255"></a>00255     <span class="keywordflow">case</span> <a class="code" href="group___d_i_m_u.html#gadf80583ef8625d74748250cf18e2acfb">DIMU_ACC_RANGE_4G</a>: <a class="code" href="group___d_i_m_u.html#ga2b0a038cf853ef2c9f46494964930c34">DIMU_Accel_divisor</a>[link] = 32.0; <span class="keywordflow">break</span>;
<a name="l00256"></a>00256     <span class="keywordflow">case</span> <a class="code" href="group___d_i_m_u.html#ga0028d43b1db87a0aacd4cb7566a805b4">DIMU_ACC_RANGE_8G</a>: <a class="code" href="group___d_i_m_u.html#ga2b0a038cf853ef2c9f46494964930c34">DIMU_Accel_divisor</a>[link] = 16.0; <span class="keywordflow">break</span>;
<a name="l00257"></a>00257   }
<a name="l00258"></a>00258 
<a name="l00259"></a>00259         <a class="code" href="group___d_i_m_u.html#gadfc6982370af0cb2087e84ad04d99ed3">DIMU_I2CRequest</a>[0] = 3;                 <span class="comment">// Sending address, register, value.</span>
<a name="l00260"></a>00260         <a class="code" href="group___d_i_m_u.html#gadfc6982370af0cb2087e84ad04d99ed3">DIMU_I2CRequest</a>[1] = <a class="code" href="group___d_i_m_u.html#ga35133720231204e0878da5ab26009294">DIMU_ACC_I2C_ADDR</a>; <span class="comment">// I2C Address of Accelerometer.</span>
<a name="l00261"></a>00261 
<a name="l00262"></a>00262         <span class="comment">//Set the Mode Control - P.25 of Documentation</span><span class="comment"></span>
<a name="l00263"></a>00263 <span class="comment">        ////////////////////////////////////////////////////////////////////////////</span>
<a name="l00264"></a>00264 <span class="comment"></span>        <a class="code" href="group___d_i_m_u.html#gadfc6982370af0cb2087e84ad04d99ed3">DIMU_I2CRequest</a>[2] = 0x16;                   <span class="comment">// Register address of Mode Control</span>
<a name="l00265"></a>00265         <a class="code" href="group___d_i_m_u.html#gadfc6982370af0cb2087e84ad04d99ed3">DIMU_I2CRequest</a>[3] = range | <a class="code" href="group___d_i_m_u.html#ga63a1a5092f122b4cb5209ec9a3cf11bd">DIMU_ACC_MODE_MEAS</a>;
<a name="l00266"></a>00266         <span class="keywordflow">if</span> (!<a class="code" href="group__common.html#gad02e06f83b264ee6fc7df41eb4712080">writeI2C</a>(link, <a class="code" href="group___d_i_m_u.html#gadfc6982370af0cb2087e84ad04d99ed3">DIMU_I2CRequest</a>))     <span class="comment">// (Port 1, Message Array, Reply Size)</span>
<a name="l00267"></a>00267           <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00268"></a>00268 
<a name="l00269"></a>00269         <a class="code" href="group___d_i_m_u.html#gae9e0c26bd535cfd590f93b9b28d4230b">DIMUcalAccel</a>(link);
<a name="l00270"></a>00270         <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00271"></a>00271 }
<a name="l00272"></a>00272 
<a name="l00273"></a>00273 <span class="comment"></span>
<a name="l00274"></a>00274 <span class="comment">/**</span>
<a name="l00275"></a>00275 <span class="comment"> * Read the specified accelerometer axis, returns an 8 bit answer</span>
<a name="l00276"></a>00276 <span class="comment"> * @param link the port number</span>
<a name="l00277"></a>00277 <span class="comment"> * @param axis the specific axis</span>
<a name="l00278"></a>00278 <span class="comment"> * @return gravity in G with 8 bit accuracy</span>
<a name="l00279"></a>00279 <span class="comment"> */</span>
<a name="l00280"></a><a class="code" href="group___d_i_m_u.html#ga89c00817a8f7463845fe5bb995104cb8">00280</a> <span class="keywordtype">float</span> <a class="code" href="group___d_i_m_u.html#ga89c00817a8f7463845fe5bb995104cb8">DIMUreadAccelAxis8Bit</a>(tSensors link, ubyte axis){
<a name="l00281"></a>00281   <span class="keywordtype">int</span> sensorReading = 0;
<a name="l00282"></a>00282         <a class="code" href="group___d_i_m_u.html#gadfc6982370af0cb2087e84ad04d99ed3">DIMU_I2CRequest</a>[0] = 2;      <span class="comment">// Sending address, register.</span>
<a name="l00283"></a>00283         <a class="code" href="group___d_i_m_u.html#gadfc6982370af0cb2087e84ad04d99ed3">DIMU_I2CRequest</a>[1] = <a class="code" href="group___d_i_m_u.html#ga35133720231204e0878da5ab26009294">DIMU_ACC_I2C_ADDR</a>;   <span class="comment">// I2C Address of accl.</span>
<a name="l00284"></a>00284 
<a name="l00285"></a>00285         <span class="keywordflow">switch</span> (axis) {
<a name="l00286"></a>00286     <span class="keywordflow">case</span> <a class="code" href="group___d_i_m_u.html#gaf85e1b013649f1a48dada5377dd37539">DIMU_ACC_X_AXIS</a>: <a class="code" href="group___d_i_m_u.html#gadfc6982370af0cb2087e84ad04d99ed3">DIMU_I2CRequest</a>[2] = 0x06; <span class="keywordflow">break</span>;
<a name="l00287"></a>00287     <span class="keywordflow">case</span> <a class="code" href="group___d_i_m_u.html#ga848aedcc8dccf9afaf4b4e122adcfdd1">DIMU_ACC_Y_AXIS</a>: <a class="code" href="group___d_i_m_u.html#gadfc6982370af0cb2087e84ad04d99ed3">DIMU_I2CRequest</a>[2] = 0x07; <span class="keywordflow">break</span>;
<a name="l00288"></a>00288     <span class="keywordflow">case</span> <a class="code" href="group___d_i_m_u.html#gaf1a0ef415e159c87a8a022ed1259e052">DIMU_ACC_Z_AXIS</a>: <a class="code" href="group___d_i_m_u.html#gadfc6982370af0cb2087e84ad04d99ed3">DIMU_I2CRequest</a>[2] = 0x08; <span class="keywordflow">break</span>;
<a name="l00289"></a>00289   }
<a name="l00290"></a>00290 
<a name="l00291"></a>00291         <span class="keywordflow">if</span> (!<a class="code" href="group__common.html#gad02e06f83b264ee6fc7df41eb4712080">writeI2C</a>(link, <a class="code" href="group___d_i_m_u.html#gadfc6982370af0cb2087e84ad04d99ed3">DIMU_I2CRequest</a>, <a class="code" href="group___d_i_m_u.html#gad1f318719870a6a10e1a86596247d7a5">DIMU_I2CReply</a>, 1))
<a name="l00292"></a>00292           <span class="keywordflow">return</span> 0;
<a name="l00293"></a>00293 
<a name="l00294"></a>00294         sensorReading = (int)<a class="code" href="group___d_i_m_u.html#gad1f318719870a6a10e1a86596247d7a5">DIMU_I2CReply</a>[0];
<a name="l00295"></a>00295         <span class="keywordflow">return</span> ((sensorReading &gt; 128) ? sensorReading - 256 : sensorReading) / <a class="code" href="group___d_i_m_u.html#ga2b0a038cf853ef2c9f46494964930c34">DIMU_Accel_divisor</a>[link];
<a name="l00296"></a>00296 }
<a name="l00297"></a>00297 
<a name="l00298"></a>00298 <span class="comment"></span>
<a name="l00299"></a>00299 <span class="comment">/**</span>
<a name="l00300"></a>00300 <span class="comment"> * Confgures an offset register for the accelerometer.</span>
<a name="l00301"></a>00301 <span class="comment"> * @param link the port number</span>
<a name="l00302"></a>00302 <span class="comment"> * @param drift_reg the register to write to</span>
<a name="l00303"></a>00303 <span class="comment"> * @param drift_LSB drift value LSB</span>
<a name="l00304"></a>00304 <span class="comment"> * @param drift_MSB drift value MSB</span>
<a name="l00305"></a>00305 <span class="comment"> * @return true if no error occured, false if it did</span>
<a name="l00306"></a>00306 <span class="comment"> */</span>
<a name="l00307"></a><a class="code" href="group___d_i_m_u.html#ga4ad63971c9ff9771f43e29183fcde431">00307</a> <span class="keywordtype">bool</span> <a class="code" href="group___d_i_m_u.html#ga4ad63971c9ff9771f43e29183fcde431">DIMUsetAccelAxisOffset</a>(tSensors link, ubyte drift_reg, ubyte drift_LSB, ubyte drift_MSB){
<a name="l00308"></a>00308   <a class="code" href="group___d_i_m_u.html#gadfc6982370af0cb2087e84ad04d99ed3">DIMU_I2CRequest</a>[0] = 3;                     <span class="comment">// Sending address, register, value.</span>
<a name="l00309"></a>00309   <a class="code" href="group___d_i_m_u.html#gadfc6982370af0cb2087e84ad04d99ed3">DIMU_I2CRequest</a>[1] = <a class="code" href="group___d_i_m_u.html#ga35133720231204e0878da5ab26009294">DIMU_ACC_I2C_ADDR</a>;     <span class="comment">// I2C Address of accl.</span>
<a name="l00310"></a>00310 
<a name="l00311"></a>00311   <a class="code" href="group___d_i_m_u.html#gadfc6982370af0cb2087e84ad04d99ed3">DIMU_I2CRequest</a>[2] = drift_reg;             <span class="comment">// Register of the data we&#39;re writing to.</span>
<a name="l00312"></a>00312   <a class="code" href="group___d_i_m_u.html#gadfc6982370af0cb2087e84ad04d99ed3">DIMU_I2CRequest</a>[3] = drift_LSB;             <span class="comment">// The drift value to write for calibration.</span>
<a name="l00313"></a>00313   <span class="keywordflow">if</span> (!<a class="code" href="group__common.html#gad02e06f83b264ee6fc7df41eb4712080">writeI2C</a>(link, <a class="code" href="group___d_i_m_u.html#gadfc6982370af0cb2087e84ad04d99ed3">DIMU_I2CRequest</a>))
<a name="l00314"></a>00314     <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00315"></a>00315 
<a name="l00316"></a>00316   <a class="code" href="group___d_i_m_u.html#gadfc6982370af0cb2087e84ad04d99ed3">DIMU_I2CRequest</a>[2] = drift_reg + 1;
<a name="l00317"></a>00317   <a class="code" href="group___d_i_m_u.html#gadfc6982370af0cb2087e84ad04d99ed3">DIMU_I2CRequest</a>[3] = drift_MSB;
<a name="l00318"></a>00318   <span class="keywordflow">return</span> <a class="code" href="group__common.html#gad02e06f83b264ee6fc7df41eb4712080">writeI2C</a>(link, <a class="code" href="group___d_i_m_u.html#gadfc6982370af0cb2087e84ad04d99ed3">DIMU_I2CRequest</a>);
<a name="l00319"></a>00319 }
<a name="l00320"></a>00320 
<a name="l00321"></a>00321 <span class="comment"></span>
<a name="l00322"></a>00322 <span class="comment">/**</span>
<a name="l00323"></a>00323 <span class="comment"> * Read the specified accelerometer axis, returns an 10 bit answer</span>
<a name="l00324"></a>00324 <span class="comment"> * @param link the port number</span>
<a name="l00325"></a>00325 <span class="comment"> * @param axis the specific axis</span>
<a name="l00326"></a>00326 <span class="comment"> * @param calibrate optional argument, if set to to true, the sensor will calibrate this axis first.</span>
<a name="l00327"></a>00327 <span class="comment"> * @return gravity in G with 10 bit accuracy</span>
<a name="l00328"></a>00328 <span class="comment"> */</span>
<a name="l00329"></a><a class="code" href="group___d_i_m_u.html#ga5a776ba768845791ae8f4ebc68bb7f61">00329</a> <span class="keywordtype">float</span> <a class="code" href="group___d_i_m_u.html#ga5a776ba768845791ae8f4ebc68bb7f61">DIMUreadAccelAxis10Bit</a>(tSensors link, ubyte axis, <span class="keywordtype">bool</span> calibrate){
<a name="l00330"></a>00330   <span class="keywordtype">int</span> ureading = 0;  <span class="comment">// unsigned sensor data</span>
<a name="l00331"></a>00331   <span class="keywordtype">int</span> sreading = 0;  <span class="comment">// signed sensor data</span>
<a name="l00332"></a>00332   <span class="keywordtype">int</span> drift_offset = 0;
<a name="l00333"></a>00333 
<a name="l00334"></a>00334   <span class="keywordflow">if</span> (calibrate == <span class="keyword">true</span>) {
<a name="l00335"></a>00335     writeDebugStreamLine(<span class="stringliteral">&quot;axis: %d&quot;</span>, axis);
<a name="l00336"></a>00336     <a class="code" href="group___d_i_m_u.html#ga4ad63971c9ff9771f43e29183fcde431">DIMUsetAccelAxisOffset</a>(link, 0x10 + axis, 0x00, 0x00);
<a name="l00337"></a>00337     wait1Msec(50);
<a name="l00338"></a>00338   }
<a name="l00339"></a>00339 
<a name="l00340"></a>00340   <a class="code" href="group___d_i_m_u.html#gadfc6982370af0cb2087e84ad04d99ed3">DIMU_I2CRequest</a>[0] = 2;          <span class="comment">// Sending address, register.</span>
<a name="l00341"></a>00341   <a class="code" href="group___d_i_m_u.html#gadfc6982370af0cb2087e84ad04d99ed3">DIMU_I2CRequest</a>[1] = <a class="code" href="group___d_i_m_u.html#ga35133720231204e0878da5ab26009294">DIMU_ACC_I2C_ADDR</a>;  <span class="comment">// I2C Address of accl.</span>
<a name="l00342"></a>00342   <a class="code" href="group___d_i_m_u.html#gadfc6982370af0cb2087e84ad04d99ed3">DIMU_I2CRequest</a>[2] = axis;        <span class="comment">// First Register of the data we&#39;re requesting.</span>
<a name="l00343"></a>00343 
<a name="l00344"></a>00344   <span class="keywordflow">if</span> (!<a class="code" href="group__common.html#gad02e06f83b264ee6fc7df41eb4712080">writeI2C</a>(link, <a class="code" href="group___d_i_m_u.html#gadfc6982370af0cb2087e84ad04d99ed3">DIMU_I2CRequest</a>, <a class="code" href="group___d_i_m_u.html#gad1f318719870a6a10e1a86596247d7a5">DIMU_I2CReply</a>, 2))
<a name="l00345"></a>00345     <span class="keywordflow">return</span> 0;
<a name="l00346"></a>00346 
<a name="l00347"></a>00347   ureading = <a class="code" href="group___d_i_m_u.html#gad1f318719870a6a10e1a86596247d7a5">DIMU_I2CReply</a>[0] + (<a class="code" href="group___d_i_m_u.html#gad1f318719870a6a10e1a86596247d7a5">DIMU_I2CReply</a>[1] &lt;&lt; 8) &amp; 0x3FF;
<a name="l00348"></a>00348   sreading = (ureading &gt; 511) ? ureading - 1024 : ureading;
<a name="l00349"></a>00349   <span class="comment">//sreading = (ureading &amp; 0x200) ? -(((~ureading) &amp; 0x3FF)+1) : ureading;</span>
<a name="l00350"></a>00350 
<a name="l00351"></a>00351   <span class="keywordflow">if</span> (calibrate == <span class="keyword">true</span>) {
<a name="l00352"></a>00352     wait1Msec(50);
<a name="l00353"></a>00353     <span class="keywordflow">switch</span> (axis) {
<a name="l00354"></a>00354       <span class="keywordflow">case</span> <a class="code" href="group___d_i_m_u.html#gaf85e1b013649f1a48dada5377dd37539">DIMU_ACC_X_AXIS</a>: drift_offset = (  0 - sreading ) * 2; <span class="keywordflow">break</span>;
<a name="l00355"></a>00355       <span class="keywordflow">case</span> <a class="code" href="group___d_i_m_u.html#ga848aedcc8dccf9afaf4b4e122adcfdd1">DIMU_ACC_Y_AXIS</a>: drift_offset = (  0 - sreading ) * 2; <span class="keywordflow">break</span>;
<a name="l00356"></a>00356       <span class="keywordflow">case</span> <a class="code" href="group___d_i_m_u.html#gaf1a0ef415e159c87a8a022ed1259e052">DIMU_ACC_Z_AXIS</a>: drift_offset = ( 64 - sreading ) * 2; <span class="keywordflow">break</span>;
<a name="l00357"></a>00357     }
<a name="l00358"></a>00358     <a class="code" href="group___d_i_m_u.html#ga4ad63971c9ff9771f43e29183fcde431">DIMUsetAccelAxisOffset</a>(link, 0x10 + axis, drift_offset &amp; 0x00ff, (drift_offset &amp; 0xff00 ) &gt;&gt; 8);
<a name="l00359"></a>00359   }
<a name="l00360"></a>00360 
<a name="l00361"></a>00361   <span class="keywordflow">return</span> sreading / 64.0;
<a name="l00362"></a>00362 }
<a name="l00363"></a>00363 
<a name="l00364"></a>00364 <span class="comment"></span>
<a name="l00365"></a>00365 <span class="comment">/**</span>
<a name="l00366"></a>00366 <span class="comment"> * Read the specified accelerometer axis, returns an 8 bit answer</span>
<a name="l00367"></a>00367 <span class="comment"> * @param link the port number</span>
<a name="l00368"></a>00368 <span class="comment"> * @param _x variable to hold X axis data</span>
<a name="l00369"></a>00369 <span class="comment"> * @param _y variable to hold Y axis data</span>
<a name="l00370"></a>00370 <span class="comment"> * @param _z variable to hold Z axis data</span>
<a name="l00371"></a>00371 <span class="comment"> */</span>
<a name="l00372"></a><a class="code" href="group___d_i_m_u.html#ga4fa39ada897e8334bec22b358db89d46">00372</a> <span class="keywordtype">void</span> <a class="code" href="group___d_i_m_u.html#ga4fa39ada897e8334bec22b358db89d46">DIMUreadAccelAxes8Bit</a>(tSensors link, <span class="keywordtype">float</span> &amp;_x, <span class="keywordtype">float</span> &amp;_y, <span class="keywordtype">float</span> &amp;_z){
<a name="l00373"></a>00373         _x = <a class="code" href="group___d_i_m_u.html#ga89c00817a8f7463845fe5bb995104cb8">DIMUreadAccelAxis8Bit</a>(link, <a class="code" href="group___d_i_m_u.html#gaf85e1b013649f1a48dada5377dd37539">DIMU_ACC_X_AXIS</a>);
<a name="l00374"></a>00374         _y = <a class="code" href="group___d_i_m_u.html#ga89c00817a8f7463845fe5bb995104cb8">DIMUreadAccelAxis8Bit</a>(link, <a class="code" href="group___d_i_m_u.html#ga848aedcc8dccf9afaf4b4e122adcfdd1">DIMU_ACC_Y_AXIS</a>);
<a name="l00375"></a>00375         _z = <a class="code" href="group___d_i_m_u.html#ga89c00817a8f7463845fe5bb995104cb8">DIMUreadAccelAxis8Bit</a>(link, <a class="code" href="group___d_i_m_u.html#gaf1a0ef415e159c87a8a022ed1259e052">DIMU_ACC_Z_AXIS</a>);
<a name="l00376"></a>00376 }
<a name="l00377"></a>00377 
<a name="l00378"></a>00378 <span class="comment"></span>
<a name="l00379"></a>00379 <span class="comment">/**</span>
<a name="l00380"></a>00380 <span class="comment"> * Read the specified accelerometer axis, returns an 10 bit answer</span>
<a name="l00381"></a>00381 <span class="comment"> * @param link the port number</span>
<a name="l00382"></a>00382 <span class="comment"> * @param _x variable to hold X axis data</span>
<a name="l00383"></a>00383 <span class="comment"> * @param _y variable to hold Y axis data</span>
<a name="l00384"></a>00384 <span class="comment"> * @param _z variable to hold Z axis data</span>
<a name="l00385"></a>00385 <span class="comment"> */</span>
<a name="l00386"></a><a class="code" href="group___d_i_m_u.html#ga3b19a2fa3659abefee9df342291e4527">00386</a> <span class="keywordtype">void</span> <a class="code" href="group___d_i_m_u.html#ga3b19a2fa3659abefee9df342291e4527">DIMUreadAccelAxes10Bit</a>(tSensors link, <span class="keywordtype">float</span> &amp;_x, <span class="keywordtype">float</span> &amp;_y, <span class="keywordtype">float</span> &amp;_z){
<a name="l00387"></a>00387         _x = <a class="code" href="group___d_i_m_u.html#ga5a776ba768845791ae8f4ebc68bb7f61">DIMUreadAccelAxis10Bit</a>(link, <a class="code" href="group___d_i_m_u.html#gaf85e1b013649f1a48dada5377dd37539">DIMU_ACC_X_AXIS</a>);
<a name="l00388"></a>00388         _y = <a class="code" href="group___d_i_m_u.html#ga5a776ba768845791ae8f4ebc68bb7f61">DIMUreadAccelAxis10Bit</a>(link, <a class="code" href="group___d_i_m_u.html#ga848aedcc8dccf9afaf4b4e122adcfdd1">DIMU_ACC_Y_AXIS</a>);
<a name="l00389"></a>00389         _z = <a class="code" href="group___d_i_m_u.html#ga5a776ba768845791ae8f4ebc68bb7f61">DIMUreadAccelAxis10Bit</a>(link, <a class="code" href="group___d_i_m_u.html#gaf1a0ef415e159c87a8a022ed1259e052">DIMU_ACC_Z_AXIS</a>);
<a name="l00390"></a>00390 }
<a name="l00391"></a>00391 
<a name="l00392"></a>00392 <span class="comment"></span>
<a name="l00393"></a>00393 <span class="comment">/**</span>
<a name="l00394"></a>00394 <span class="comment"> * Calibrate the Accelerometer.  The sensor must be stationary and assumes the Z axis is facing up.</span>
<a name="l00395"></a>00395 <span class="comment"> * @param link the port number</span>
<a name="l00396"></a>00396 <span class="comment"> */</span>
<a name="l00397"></a><a class="code" href="group___d_i_m_u.html#gae9e0c26bd535cfd590f93b9b28d4230b">00397</a> <span class="keywordtype">void</span> <a class="code" href="group___d_i_m_u.html#gae9e0c26bd535cfd590f93b9b28d4230b">DIMUcalAccel</a>(tSensors link){
<a name="l00398"></a>00398   <a class="code" href="group___d_i_m_u.html#ga5a776ba768845791ae8f4ebc68bb7f61">DIMUreadAccelAxis10Bit</a>(link, <a class="code" href="group___d_i_m_u.html#gaf85e1b013649f1a48dada5377dd37539">DIMU_ACC_X_AXIS</a>, <span class="keyword">true</span>);      <span class="comment">// Get x axis data.</span>
<a name="l00399"></a>00399         <a class="code" href="group___d_i_m_u.html#ga5a776ba768845791ae8f4ebc68bb7f61">DIMUreadAccelAxis10Bit</a>(link, <a class="code" href="group___d_i_m_u.html#ga848aedcc8dccf9afaf4b4e122adcfdd1">DIMU_ACC_Y_AXIS</a>, <span class="keyword">true</span>);      <span class="comment">// Get y axis data.</span>
<a name="l00400"></a>00400         <a class="code" href="group___d_i_m_u.html#ga5a776ba768845791ae8f4ebc68bb7f61">DIMUreadAccelAxis10Bit</a>(link, <a class="code" href="group___d_i_m_u.html#gaf1a0ef415e159c87a8a022ed1259e052">DIMU_ACC_Z_AXIS</a>, <span class="keyword">true</span>);      <span class="comment">// Get z axis data.</span>
<a name="l00401"></a>00401         wait1Msec(100);
<a name="l00402"></a>00402 }
<a name="l00403"></a>00403 
<a name="l00404"></a>00404 
<a name="l00405"></a><a class="code" href="group___d_i_m_u.html#ga3c0d3332e0fb25fc3a271733ea577a49">00405</a> <span class="keywordtype">bool</span> <a class="code" href="group___d_i_m_u.html#ga3c0d3332e0fb25fc3a271733ea577a49">DIMUconfigIMU</a>(tSensors link, ubyte accelRange, ubyte gyroRange, <span class="keywordtype">bool</span> lpfenable)
<a name="l00406"></a>00406 {
<a name="l00407"></a>00407   <span class="keywordflow">if</span> (!<a class="code" href="group___d_i_m_u.html#ga6e9ba4ee66fd46ccf2bc506870289034">DIMUconfigGyro</a>(link, gyroRange, lpfenable))
<a name="l00408"></a>00408     <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00409"></a>00409 
<a name="l00410"></a>00410   <span class="keywordflow">return</span> <a class="code" href="group___d_i_m_u.html#gae23d7e3cdc85d3113a302cb094c2746c">DIMUconfigAccel</a>(link, accelRange);
<a name="l00411"></a>00411 }
<a name="l00412"></a>00412 
<a name="l00413"></a>00413 
<a name="l00414"></a>00414 <span class="preprocessor">#ifdef STRUCT_CODE_ENABLED</span>
<a name="l00415"></a>00415 <span class="preprocessor"></span><span class="keywordtype">bool</span> <a class="code" href="group___d_i_m_u.html#ga6e9ba4ee66fd46ccf2bc506870289034">DIMUconfigGyro</a>(tDIMUdataPtr sensor, ubyte range, <span class="keywordtype">bool</span> lpfenable)
<a name="l00416"></a>00416 {
<a name="l00417"></a>00417         memset(sensor-&gt;I2CRequest, 0, <span class="keyword">sizeof</span>(<a class="code" href="group__common.html#gaa172ef131853460e5b9f5c6db81d30f4">tByteArray</a>));
<a name="l00418"></a>00418 
<a name="l00419"></a>00419         <span class="comment">// Setup the size and address, same for all requests.</span>
<a name="l00420"></a>00420         sensor-&gt;I2CRequest[0] = 3;    <span class="comment">// Sending address, register, value. Optional, defaults to true</span>
<a name="l00421"></a>00421         sensor-&gt;I2CRequest[1] = 0xD2; <span class="comment">// I2C Address of gyro.</span>
<a name="l00422"></a>00422 
<a name="l00423"></a>00423         <span class="comment">// Write CTRL_REG2</span>
<a name="l00424"></a>00424         <span class="comment">// No High Pass Filter</span>
<a name="l00425"></a>00425         sensor-&gt;I2CRequest[2] = <a class="code" href="group___d_i_m_u.html#ga5489c8f619ba50cbf14780c9d307659f">DIMU_GYRO_CTRL_REG2</a>;
<a name="l00426"></a>00426         sensor-&gt;I2CRequest[3] = 0x00;
<a name="l00427"></a>00427         <span class="keywordflow">if</span> (!<a class="code" href="group__common.html#gad02e06f83b264ee6fc7df41eb4712080">writeI2C</a>(link, sensor-&gt;I2CRequest))
<a name="l00428"></a>00428           <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00429"></a>00429 
<a name="l00430"></a>00430         <span class="comment">// Write CTRL_REG3</span>
<a name="l00431"></a>00431         <span class="comment">// No interrupts.  Date ready.</span><span class="comment"></span>
<a name="l00432"></a>00432 <span class="comment">        ////////////////////////////////////////////////////////////////////////////</span>
<a name="l00433"></a>00433 <span class="comment"></span>        sensor-&gt;I2CRequest[2] = <a class="code" href="group___d_i_m_u.html#ga398639d7a669cc18b41ef3e658f14957">DIMU_GYRO_CTRL_REG3</a>;      <span class="comment">// Register address of CTRL_REG3</span>
<a name="l00434"></a>00434         sensor-&gt;I2CRequest[3] = 0x08;      <span class="comment">// No interrupts.  Date ready.</span>
<a name="l00435"></a>00435         <span class="keywordflow">if</span>(!<a class="code" href="group__common.html#gad02e06f83b264ee6fc7df41eb4712080">writeI2C</a>(link, sensor-&gt;I2CRequest))
<a name="l00436"></a>00436           <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00437"></a>00437 
<a name="l00438"></a>00438         <span class="comment">// Write CTRL_REG4</span>
<a name="l00439"></a>00439         <span class="comment">// Full scale range.</span>
<a name="l00440"></a>00440         sensor-&gt;I2CRequest = <a class="code" href="group___d_i_m_u.html#gab89482d8076471665dfa28d9d26d8bd0">DIMU_GYRO_CTRL_REG4</a>;
<a name="l00441"></a>00441         sensor-&gt;I2CRequest[3] = range + <a class="code" href="group___d_i_m_u.html#gae226ad04bfffc67111cf83c3e7f31e7b">DIMU_CTRL4_BLOCKDATA</a>;
<a name="l00442"></a>00442         <a class="code" href="group__common.html#gad02e06f83b264ee6fc7df41eb4712080">writeI2C</a>(link, sensor-&gt;I2CRequest);
<a name="l00443"></a>00443 
<a name="l00444"></a>00444         <span class="comment">//Write CTRL_REG5</span>
<a name="l00445"></a>00445         sensor-&gt;I2CRequest[2] = <a class="code" href="group___d_i_m_u.html#ga42de6d011cc592df664b6ebe3cb55a2d">DIMU_GYRO_CTRL_REG5</a>;      <span class="comment">// Register address of CTRL_REG5</span>
<a name="l00446"></a>00446         sensor-&gt;I2CRequest[3] = (lpfenable) ? 0x02 : 0x00;      <span class="comment">// filtering - low pass</span>
<a name="l00447"></a>00447         <span class="keywordflow">if</span> (!<a class="code" href="group__common.html#gad02e06f83b264ee6fc7df41eb4712080">writeI2C</a>(link, sensor-&gt;I2CRequest))
<a name="l00448"></a>00448           <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00449"></a>00449 
<a name="l00450"></a>00450         <span class="comment">// Write CTRL_REG1</span>
<a name="l00451"></a>00451         <span class="comment">// Enable all axes. Disable power down.</span>
<a name="l00452"></a>00452         sensor-&gt;I2CRequest[2] = <a class="code" href="group___d_i_m_u.html#gac784c892e42b04ab2543a5f98f57322d">DIMU_GYRO_CTRL_REG1</a>;
<a name="l00453"></a>00453         sensor-&gt;I2CRequest[3] = 0x0F;
<a name="l00454"></a>00454         <span class="keywordflow">if</span> (!<a class="code" href="group__common.html#gad02e06f83b264ee6fc7df41eb4712080">writeI2C</a>(link, sensor-&gt;I2CRequest))
<a name="l00455"></a>00455           <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00456"></a>00456 
<a name="l00457"></a>00457         <span class="comment">// Set DIMU_Gyro_divisor so that the output of our gyro axis readings can be turned</span>
<a name="l00458"></a>00458         <span class="comment">// into scaled values.</span><span class="comment"></span>
<a name="l00459"></a>00459 <span class="comment">        ///////////////////////////////////////////////////////////////////////////</span>
<a name="l00460"></a>00460 <span class="comment"></span>        <span class="keywordflow">if</span>(range == 0)
<a name="l00461"></a>00461           <a class="code" href="group___d_i_m_u.html#ga6f1c4ca2d865d44c5263abb502045c62">DIMU_Gyro_divisor</a>[link] = 114.28571;      <span class="comment">// Full scale range is 250 dps.</span>
<a name="l00462"></a>00462   <span class="keywordflow">else</span> <span class="keywordflow">if</span> (range == 0x10)
<a name="l00463"></a>00463     <a class="code" href="group___d_i_m_u.html#ga6f1c4ca2d865d44c5263abb502045c62">DIMU_Gyro_divisor</a>[link] = 57.142857;       <span class="comment">// Full scale range is 500 dps.</span>
<a name="l00464"></a>00464         <span class="keywordflow">else</span> <span class="keywordflow">if</span> (range == 0x30)
<a name="l00465"></a>00465           <a class="code" href="group___d_i_m_u.html#ga6f1c4ca2d865d44c5263abb502045c62">DIMU_Gyro_divisor</a>[link] = 14.285714;       <span class="comment">// Full scale range is 2000 dps.</span>
<a name="l00466"></a>00466 
<a name="l00467"></a>00467         <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00468"></a>00468 }
<a name="l00469"></a>00469 
<a name="l00470"></a>00470 <span class="keywordtype">void</span> <a class="code" href="group___d_i_m_u.html#gab827ec900619ac00a404286787bd4374">DIMUreadGyroAxes</a>(tDIMUdataPtr sensor)
<a name="l00471"></a>00471 {
<a name="l00472"></a>00472 
<a name="l00473"></a>00473 }
<a name="l00474"></a>00474 <span class="keywordtype">bool</span> <a class="code" href="group___d_i_m_u.html#gae23d7e3cdc85d3113a302cb094c2746c">DIMUconfigAccel</a>(tDIMUdataPtr sensor, ubyte range)
<a name="l00475"></a>00475 {
<a name="l00476"></a>00476 
<a name="l00477"></a>00477 }
<a name="l00478"></a>00478 <span class="keywordtype">void</span> <a class="code" href="group___d_i_m_u.html#ga4fa39ada897e8334bec22b358db89d46">DIMUreadAccelAxes8Bit</a>(tDIMUdataPtr sensor)
<a name="l00479"></a>00479 {
<a name="l00480"></a>00480 
<a name="l00481"></a>00481 }
<a name="l00482"></a>00482 <span class="keywordtype">void</span> <a class="code" href="group___d_i_m_u.html#ga3b19a2fa3659abefee9df342291e4527">DIMUreadAccelAxes10Bit</a>(tDIMUdataPtr sensor)
<a name="l00483"></a>00483 {
<a name="l00484"></a>00484 
<a name="l00485"></a>00485 }
<a name="l00486"></a>00486 <span class="keywordtype">void</span> <a class="code" href="group___d_i_m_u.html#gae9e0c26bd535cfd590f93b9b28d4230b">DIMUcalAccel</a>(tDIMUdataPtr sensor)
<a name="l00487"></a>00487 {
<a name="l00488"></a>00488 
<a name="l00489"></a>00489 }
<a name="l00490"></a>00490 <span class="keywordtype">bool</span> <a class="code" href="group___d_i_m_u.html#ga3c0d3332e0fb25fc3a271733ea577a49">DIMUconfigIMU</a>(tDIMUdataPtr sensor, ubyte accelRange, ubyte gyroRange, <span class="keywordtype">bool</span> lpfenable)
<a name="l00491"></a>00491 {
<a name="l00492"></a>00492 
<a name="l00493"></a>00493 }
<a name="l00494"></a>00494 <span class="preprocessor">#endif</span>
<a name="l00495"></a>00495 <span class="preprocessor"></span>
<a name="l00496"></a>00496 <span class="preprocessor">#endif // __DIMU_H__</span>
<a name="l00497"></a>00497 <span class="preprocessor"></span>
<a name="l00498"></a>00498 <span class="comment">/*</span>
<a name="l00499"></a>00499 <span class="comment"> * $Id: dexterind-imu.h 133 2013-03-10 15:15:38Z xander $</span>
<a name="l00500"></a>00500 <span class="comment"> */</span>
<a name="l00501"></a>00501 <span class="comment">/* @} */</span>
<a name="l00502"></a>00502 <span class="comment">/* @} */</span>
</pre></div></div>
</div>
<hr class="footer"/><address class="footer"><small>Generated on Wed Mar 13 2013 19:56:42 for ROBOTC Drivers by&#160;
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.2 </small></address>
</body>
</html>
